//最上面写第三方包
import Vue from 'vue'
import VueRouter from 'vue-router'

//中间写自己的公共方法（下面这个是举例，没有写过）
// import setName from '@/utils/index.js'

//底部写组件的引入
import Login from '@/view/login'
import Article from '@/view/article'
import Register from '@/view/register'
import List from '@/view/list'
import NotFound from '@/view/NotFound'

Vue.use(VueRouter)

const router = new VueRouter({
  //配置路由规则
  mode: 'history',

  //配置路由规则
  routes: [
    {
      path: '/',
      redirect: '/article',
    },
    {
      path: '/login',
      component: Login,
    },
    {
      path: '/article',
      component: Article,
    },
    {
      path: '/register/:username/:age',
      component: Register,
    },
    {
      path: '/list',
      component: List,
    },
    {
      path: '*',
      component: NotFound,
    },
  ],
})

export default router
